﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace ENG.EngStartQueue.Counters
{
  internal class CultureCounters : List<CultureCounter>
  {
    internal static CultureCounters Load(string fileName)
    {
      CultureCounters ret = new CultureCounters();

      XDocument doc = XDocument.Load(fileName);

      XElement root = doc.Root;
      IEnumerable<XElement> ccs = root.Elements();
      CultureCounter cc = null;

      foreach (XElement fItem in ccs)
      {
        cc = CultureCounter.Load(fItem);
        ret.Add(cc);
      } // foreach (XElement fItem in ccs)

      return ret;
    }


    internal CultureCounter GetByIetf(string p)
    {
      CultureCounter ret = null;

      foreach (var fItem in this)
      {
        if (fItem.Language.StartsWith(p))
        {
          ret = fItem;
          break;
        }
      } // foreach (var fItem in this)

      return ret;
    }
  }

}
